package com.table;

import com.appclient.ControlledScreen;
import com.appclient.DaoInstanceEnum;
import com.appclient.ScreensController;
import com.carpark.ejb.Model.TarrifsModel;
import com.wizardOther.Items.ValidationForm;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ListView;

/**
 *
 * @author Vi
 */
public class TariffTableControllerDisp extends ValidationForm implements Initializable, ControlledScreen {

    private ScreensController myController;
    @FXML
    private ListView<String> persList;
    private ObservableList<String> persData = FXCollections.observableArrayList();
    @FXML
    private ListView<String> traList;
    private ObservableList<String> traData = FXCollections.observableArrayList();
    @FXML
    private ListView<String> vanList;
    private ObservableList<String> vanData = FXCollections.observableArrayList();
    @FXML
    private ListView<String> motoList;
    private ObservableList<String> motoData = FXCollections.observableArrayList();

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        persList.setItems(persData);
        traList.setItems(traData);
        motoList.setItems(motoData);
        vanList.setItems(vanData);
    }

    public TariffTableControllerDisp() {
        List<TarrifsModel> personal = DaoInstanceEnum.INSTANCE.getDao().getTarrifsByCarType("Personal");
        for (TarrifsModel tr : personal) {
            persData.add(tr.getName() + ", cena: " + tr.getRank() + " zł ");
        }
        List<TarrifsModel> van = DaoInstanceEnum.INSTANCE.getDao().getTarrifsByCarType("Van");
        for (TarrifsModel tr : van) {
            vanData.add(tr.getName() + ", cena: " + tr.getRank() + " zł ");
        }

        List<TarrifsModel> moto = DaoInstanceEnum.INSTANCE.getDao().getTarrifsByCarType("Motorcycle");
        for (TarrifsModel tr : moto) {
            motoData.add(tr.getName() + ", cena: " + tr.getRank() + " zł ");
        }
        List<TarrifsModel> trailers = DaoInstanceEnum.INSTANCE.getDao().getTarrifsByCarType("Trailer");
        for (TarrifsModel tr : trailers) {
            traData.add(tr.getName() + ", cena: " + tr.getRank() + " zł ");
        }
    }

    @FXML
    private void initialize() {
    }

    private void updateFilteredData() {
    }

    @Override
    public void setScreenParent(ScreensController screenParent) {
        myController = screenParent;
        initialize();
    }
}
